package com.jasic.common;

import com.jasic.util.XMLReader;
import org.dom4j.Node;

public class Global {
    private static XMLReader xmlReader = new XMLReader(Env.getConfigFile());

    /**
     * Get the log4j configurations....
     *
     * @return
     */
    public static String get_log4j_config() {

        String value = null;
        Node node = xmlReader.getSingleNode("//log4j/pro");

        try {
            value = node.getStringValue();
        } catch (Exception e) {
            throw new RuntimeException("the node of //log4j/pro must be a String type!", e);
        }

        return value;
    }

    /**
     * 监控socket连接时间间隔
     *
     * @return
     */
    public static int get_socket_monitor_interval() {

        int value = 0;

        try {
            Node node = xmlReader.getSingleNode("//connt/interval");
            value = Integer.parseInt(node.getStringValue());
        } catch (Exception e) {
            throw new RuntimeException("the node of //log4j/pro must be a String type!", e);
        }
        return value;
    }

    public static void main(String[] args) {
        System.out.println(get_socket_monitor_interval());
    }
}